package com.ruoyi.cms.controller;

import com.ruoyi.cms.domain.CmsSiteInfo;
import com.ruoyi.cms.service.ICmsSiteInfoService;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
public class CmsWebController {
    @Autowired
    private ICmsSiteInfoService cmsSiteInfoService;

    /**
     * 模态窗口
     */
    @GetMapping("/index")
    public String index(Model model) {
        CmsSiteInfo params = new CmsSiteInfo();
        params.setStatus(Constants.SUCCESS);
        PageUtils.startPage(1, 1, "info_id desc");
        List<CmsSiteInfo> infos = cmsSiteInfoService.selectCmsSiteInfoList(params);
        if (infos.isEmpty()) {
            throw new RuntimeException("未设置站点信息");
        }
        model.addAttribute("info", infos.get(0));
        return "index";
    }

}
